﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VehicleConfigurator.Model
{
    public class OptionPrice
    {
        private string dealerNetPrice;
        private string dealerNetPriceVAT;
        private string retailPrice;
        private string retailPriceVAT;

        private string taxAmount1;

        public string TaxAmount1
        {
            get
            {
                if (string.IsNullOrEmpty(taxAmount1))
                {
                    return "0";
                }
                else
                {
                    return taxAmount1;
                }
            }
            set { taxAmount1 = value; }
        }
        private string taxAmount2;

        public string TaxAmount2
        {
            get
            {
                if (string.IsNullOrEmpty(taxAmount2))
                {
                    return "0";
                }
                else
                {
                    return taxAmount2;
                }
            }
            set { taxAmount2 = value; }
        }
        private string taxAmount3;

        public string TaxAmount3
        {
            get
            {
                if (string.IsNullOrEmpty(taxAmount3))
                {
                    return "0";
                }
                else
                {
                    return taxAmount3;
                }
            }
            set { taxAmount3 = value; }
        }
        private string taxPercentage1;

        public string TaxPercentage1
        {
            get
            {
                if (string.IsNullOrEmpty(taxPercentage1))
                {
                    return "0";
                }
                else
                {
                    return taxPercentage1;
                }
            }
            set { taxPercentage1 = value; }
        }
        private string taxPercentage2;

        public string TaxPercentage2
        {
            get
            {
                if (string.IsNullOrEmpty(taxPercentage2))
                {
                    return "0";
                }
                else
                {
                    return taxPercentage2;
                }
            }
            set { taxPercentage2 = value; }
        }
        private string taxPercentage3;

        public string TaxPercentage3
        {
            get
            {
                if (string.IsNullOrEmpty(taxPercentage3))
                {
                    return "0";
                }
                else
                {
                    return taxPercentage3;
                }
            }
            set { taxPercentage3 = value; }
        }

        public int OID { get; set; }
        public int OptionOID { get; set; }
        public int ModelEditionOID { get; set; }
        public int ModelYearOID { get; set; }
        public DateTime PriceListDate { get; set; }
        public int CountryOID { get; set; }
        public int CurrencyOID { get; set; }
        //public string TaxPercentage1 { get; set; }
        //public string TaxPercentage2 { get; set; }
        //public string TaxPercentage3 { get; set; }
        //public string TaxAmount1 { get; set; }
        //public string TaxAmount2 { get; set; }
        //public string TaxAmount3 { get; set; }

        public string DealerNetPrice
        {
            get
            {
                if (string.IsNullOrEmpty(dealerNetPrice))
                {
                    return "0";
                }
                else
                {
                    return dealerNetPrice;
                }
            }
            set
            {
                dealerNetPrice = value;
            }
        }
        public string RetailPrice
        {
            get
            {
                if (string.IsNullOrEmpty(retailPrice))
                {
                    return "0";
                }
                else
                {
                    return retailPrice;
                }
            }
            set
            {
                retailPrice = value;
            }
        }
        public string DealerNetPriceVAT
        {
            get
            {
                if (string.IsNullOrEmpty(dealerNetPriceVAT))
                {
                    return "0";
                }
                else
                {
                    return dealerNetPriceVAT;
                }
            }
            set
            {
                dealerNetPriceVAT = value;
            }
        }
        public string RetailPriceVAT {
            get
            {
                if (string.IsNullOrEmpty(retailPriceVAT))
                {
                    return "0";
                }
                else
                {
                    return retailPriceVAT;
                }
            }
            set
            {
                retailPriceVAT = value;
            }
        }

        private string description;
        public string Description
        {
            get
            {
                if (string.IsNullOrEmpty(description))
                {
                    return string.Empty;
                }
                else
                {
                    return description.Replace("'", "\\'");//.Replace("\"", "\\\"");
                }
            }
            set { description = value; }
        }

        public Option Option { get; set; }

        public OptionPrice()
        {
            this.Description = "";
            this.TaxAmount1 = null;
            this.TaxAmount2 = null;
            this.TaxAmount3 = null;
            this.TaxPercentage1 = null;
            this.TaxPercentage2 = null;
            this.TaxPercentage3 = null;

            this.DealerNetPrice = null;
            this.RetailPrice = null;
            this.DealerNetPriceVAT = null;
            this.RetailPriceVAT = null;


        }

        public OptionPrice Copy()
        {
            var optionPrice = new OptionPrice();
            optionPrice.CountryOID = this.CountryOID;
            optionPrice.CurrencyOID = this.CurrencyOID;
            optionPrice.DealerNetPrice = this.DealerNetPrice;
            optionPrice.DealerNetPriceVAT = this.DealerNetPriceVAT;
            optionPrice.Description = this.Description;
            optionPrice.ModelEditionOID = this.ModelEditionOID;
            optionPrice.ModelYearOID = this.ModelYearOID;
            optionPrice.OID = this.OID;
            optionPrice.Option = this.Option.Copy();
            optionPrice.OptionOID = this.OptionOID;
            optionPrice.PriceListDate = this.PriceListDate;
            optionPrice.RetailPrice = this.RetailPrice;
            optionPrice.RetailPriceVAT = this.RetailPriceVAT;
            optionPrice.TaxAmount1 = this.TaxAmount1;
            optionPrice.TaxAmount2 = this.TaxAmount2;
            optionPrice.TaxAmount3 = this.TaxAmount3;
            optionPrice.TaxPercentage1 = this.TaxPercentage1;
            optionPrice.TaxPercentage2 = this.TaxPercentage2;
            optionPrice.TaxPercentage3 = this.TaxPercentage3;
            return optionPrice;
        }
    }
}
